package com.sfzd5.exam.helplibrary.exam.answersheet;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
/*
记录题目，每题几个小题，每个小题多少空，每空多少空格数
每行7mm高

        每行180mm - 6mm， 通过计算得出换行点
*/
public class BlankAnswerSheetQuestion extends AnswerSheetQuestion {
    public BlankAnswerSheetQuestion(){
        areaType = Area.AreaType.Blank;
    }
    public BlankAnswerSheetQuestion(AnswerSheetQuestion answerSheetQuestion)
    {
        this.id = answerSheetQuestion.id;
        this.areaType = answerSheetQuestion.areaType;
        this.infoJson = answerSheetQuestion.infoJson;
        this.questionId = answerSheetQuestion.questionId;
        this.answer = answerSheetQuestion.answer;
        this.score = answerSheetQuestion.score;
    }
    public List<BlankInfo> getBlankInfoList() {
        if(blankInfoList==null){
            if(infoJson!=null && !infoJson.isEmpty()){
                Type type = new TypeToken<ArrayList<BlankInfo>>(){}.getType();
                blankInfoList = new Gson().fromJson(infoJson, type);
            } else {
                blankInfoList = new ArrayList<>();
            }
        }
        return blankInfoList;
    }

    public void setBlankInfoList(List<BlankInfo> blankInfoList) {
        this.blankInfoList = blankInfoList;
        this.infoJson = new Gson().toJson(blankInfoList);
    }

    private List<BlankInfo> blankInfoList = null;

    @Override
    public String toString() {
        return String.format("填空题");
    }
}
